package com.woniuxy.user.controller;

import com.woniuxy.commons.request.ResPage;
import com.woniuxy.commons.request.ResponseResult;
import com.woniuxy.user.entity.Perms;
import com.woniuxy.user.service.PermsService;
import com.woniuxy.user.vo.AddPermsVo;
import com.woniuxy.user.vo.PermsVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/perms")
public class PermsController {
    @Resource
    private PermsService permsService;

    /**
     * 通过角色id查询对应权限列表
     */
    @GetMapping("/getPermsByRid")
    public ResponseResult<ResPage<Perms>> getPermsByRid(PermsVo permsVo){
        return new ResponseResult<>(ResponseResult.OK,permsService.getPermsByRid(permsVo));
    }
    /**
     * 添加权限
     */
    @PostMapping("/addPerms")
    public ResponseResult<Boolean> addPerms(@RequestBody AddPermsVo addPermsVo){
        return new ResponseResult<>(ResponseResult.OK,permsService.addPerms(addPermsVo));
    }
    /**
     * 修改权限
     */
    @PutMapping("/editPerms")
    public ResponseResult<Boolean> editPerms(@RequestBody Perms perms){
        return new ResponseResult<>(ResponseResult.OK,permsService.editPerms(perms));
    }
    /**
     * 删除权限
     */
    @DeleteMapping("/deletePerms/{id}")
    public ResponseResult<Boolean> deletePerms(@PathVariable("id") Integer id){
        return new ResponseResult<>(ResponseResult.OK,permsService.deletePerms(id));
    }
}
